<?php
/**
 * Created by PhpStorm.
 * User: linyh
 * Date: 2017/11/25 0025 10:13
 */
?>
<link href="/ueditor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet" />

<section class="content-header">
    <h1>
        修改关税
    </h1>
</section>

<!-- Main content -->
<section class="content">
<div class="row">
    <div class="col-md-12">
        <!-- general form elements -->
        <div class="box box-default">
            <!-- /.box-header -->
            <!-- form start -->
            <form id="form" role="form" class="form-horizontal">
                <div class="box-body">
                    <div class="form-group">
                        <label for="import_duty" class="col-sm-5 control-label">进口税</label>
                        <div class="col-sm-4">
                        <input id="import_duty" class="form-control" type="number" step="0.01" max="0.5" name="import_duty" value="<?=Yii::$app->user->identity->user->country->import_duty?>" placeholder="请输入进口税">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="export_tax"  class="col-sm-5 control-label">出口税</label>
                        <div class="col-sm-4">
                        <input id="export_tax" class="form-control" type="number" step="0.01" max="0.5" name="export_tax" value="<?=Yii::$app->user->identity->user->country->export_tax?>" placeholder="请输入出口税">
                        </div>
                    </div>
                </div>
                <!-- /.box-body -->

                <div class="box-footer text-center">
                    <button type="submit" class="btn btn-success">提交</button>
                </div>
            </form>
        </div>
    </div>
</div>
</section>

<script>
$('#form').submit(function(e) {
    e.preventDefault();
    var str = $('#form').serialize();

    $.ajax('/api/country/tax', {
        type: 'POST',
        data: str,
        dataType: 'json',
        headers: {'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest'}
    }).then(function(ret) {
        if(ret.state ==0) {
            alert('关税修改成功');
            location.reload();
        } else {
            alert(ret.message);
        }
    });
});

</script>